<template>
  <div class="right">
    <div class="right-side-img"></div>
  </div>
  <div class="tou">
    <div class="tou_2">
      <router-link
        :to="{
          path: `/index/${mail.qq}`,
        }"
        ><img src="../assets/image/head_logo.png"
      /></router-link>
    </div>
    <div class="tou_3">
      <img src="../assets/image/logo.webp" />
    </div>
    <nav>
      <ol class="breadcrumb">
        <li>
          <router-link
            :to="{
              name: 'dl',
            }"
            >{{ qq_ ? "请QQ登录" : " " }}</router-link
          >
          <div style="cursor: pointer" @click="Mail_index()">
            <img
              :title="mail.qq"
              style="width: 30px"
              :src="getAssetsFile(mail.mail_img)"
            />
          </div>
        </li>
        <li>
          <div @click="logoutHandle()" v-if="dl_img">退出</div>
        </li>
        <li>
          <el-badge :value="gwces.length">
            <router-link
              :to="{
                path: `/gwc/${mail.qq}`,
              }"
              ><img v-if="dl_img" src="../assets/image/gwc.png"
            /></router-link>
          </el-badge>
        </li>
        <li><a href="#">周边公告</a></li>
        <li>帮助中心</li>
        <li><a href="#">手机周边</a></li>
      </ol>
    </nav>
  </div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { getAssetsFile } from "../assets/img";
import { RouterLink, useRouter, useRoute } from "vue-router";
import axios from "axios";

const route = useRoute();
const router = useRouter();
const dl_img = ref(false);
const qq_ = ref("1");
const mail: any = ref({});
/**用户*/
mail.value.qq = route.params.qq;
const Mail = () => {
  axios.get("http://127.0.0.1:1234/U/" + mail.value.qq).then((response) => {
    mail.value = response.data;
    console.log(mail.value);
    if (mail.value.qq !== "") {
      dl_img.value = true;
      qq_.value = "";
    } else {
      dl_img.value = false;
      qq_.value = "1";
    }
  });
};
Mail();

//个人主页
const Mail_index = () => {
  router.push({ path: `/Lex/${mail.value.qq}` });
};

/**退出登录*/
const logoutHandle = () => {
  localStorage.removeItem("qq");
  location.href = "/index";
};

const g: any = ref({});
const gwces = ref([]);
/**购物车*/
const StuNGwc = () => {
  axios.post("http://127.0.0.1:1234/G/spper", g.value).then((response) => {
    g.value = response.data;
    gwces.value = g.value.filter((f) => f.gqq == mail.value.qq);
  });
};
StuNGwc();
</script>
<style scoped>
@import "../assets/css/TandW.css";
</style>
